import request from '@/config/axios'
import type { RegisterVO, UserLoginVO } from './types'

export interface SmsCodeVO {
  mobile: string
  scene: number
}

export interface SmsLoginVO {
  mobile: string
  code: string
}

// 登录
export const login = (data: UserLoginVO) => {
  return request.post({
    url: '/admin/sys/syslogin/login',
    data,
    headers: {
      isEncrypt: false
    }
  })
}

// 注册
export const register = (data: RegisterVO) => {
  return request.post({ url: '/admin/sys/syslogin/register', data })
}

// 登出
export const loginOut = () => {
  return request.post({ url: '/admin/sys/syslogin/logout' })
}

// 获取用户权限信息
export const getInfo = () => {
  return request.get({ url: '/admin/sys/syslogin/getpermissioninfo' })
}

// 获取验证图片以及 token
export const getCode = (data: any) => {
  return request.postOriginal({ url: '/admin/sys/syscaptcha/get', data })
}

// 滑动或者点选验证
export const reqCheck = (data: any) => {
  return request.postOriginal({ url: '/admin/sys/syscaptcha/check', data })
}

// 通过短信重置密码
export const smsResetPassword = (data: any) => {
  return request.post({ url: '/system/auth/reset-password', data })
}

//获取登录验证码
export const sendSmsCode = (data: SmsCodeVO) => {
  return request.post({ url: '/system/auth/send-sms-code', data })
}
